﻿using System;
using System.Data;
using System.Collections.Generic;
using Chenxin.Lib.Business.Entity;
namespace Chenxin.Lib.Business.BLL
{
    /// <summary>
    /// 业务逻辑类t_Intention_BaseInfo 的摘要说明。
    /// </summary>
    public class t_Intention_BaseInfo
    {
        public t_Intention_BaseInfo()
        { }
        #region  成员方法
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(Chenxin.Lib.Business.Entity.t_Intention_BaseInfo model)
        {
            Chenxin.Lib.Business.DAL.t_Intention_BaseInfo.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Chenxin.Lib.Business.Entity.t_Intention_BaseInfo model)
        {
            Chenxin.Lib.Business.DAL.t_Intention_BaseInfo.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public void Delete(Guid IntentionId)
        {

            Chenxin.Lib.Business.DAL.t_Intention_BaseInfo.Delete(IntentionId);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Chenxin.Lib.Business.Entity.t_Intention_BaseInfo GetModel(Guid IntentionId)
        {

            return Chenxin.Lib.Business.DAL.t_Intention_BaseInfo.GetModel(IntentionId);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Chenxin.Lib.Business.Entity.t_Intention_BaseInfo GetBillInfo(Guid IntentionId)
        {
            return Chenxin.Lib.Business.DAL.t_Intention_BaseInfo.GetBillInfo(IntentionId);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return Chenxin.Lib.Business.DAL.t_Intention_BaseInfo.GetList(strWhere);
        }
        
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Chenxin.Lib.Business.Entity.t_Intention_BaseInfo> GetModelList(string strWhere)
        {
            DataSet ds = Chenxin.Lib.Business.DAL.t_Intention_BaseInfo.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Chenxin.Lib.Business.Entity.t_Intention_BaseInfo> DataTableToList(DataTable dt)
        {
            List<Chenxin.Lib.Business.Entity.t_Intention_BaseInfo> modelList = new List<Chenxin.Lib.Business.Entity.t_Intention_BaseInfo>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Chenxin.Lib.Business.Entity.t_Intention_BaseInfo model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Chenxin.Lib.Business.Entity.t_Intention_BaseInfo();
                    if (dt.Rows[n]["IntentionId"].ToString() != "")
                    {
                        model.IntentionId = new Guid(dt.Rows[n]["IntentionId"].ToString());
                    }
                    if (dt.Rows[n]["bContracted"].ToString() != "")
                    {
                        if ((dt.Rows[n]["bContracted"].ToString() == "1") || (dt.Rows[n]["bContracted"].ToString().ToLower() == "true"))
                        {
                            model.bContracted = true;
                        }
                        else
                        {
                            model.bContracted = false;
                        }
                    }
                    if (dt.Rows[n]["ContractId"].ToString() != "")
                    {
                        model.ContractId = new Guid(dt.Rows[n]["ContractId"].ToString());
                    }
                    model.ContractCode = dt.Rows[n]["ContractCode"].ToString();
                    model.IntentionCode = dt.Rows[n]["IntentionCode"].ToString();
                    if (dt.Rows[n]["CreateDate"].ToString() != "")
                    {
                        model.CreateDate = DateTime.Parse(dt.Rows[n]["CreateDate"].ToString());
                    }
                    if (dt.Rows[n]["CreateEmpId"].ToString() != "")
                    {
                        model.CreateEmpId = new Guid(dt.Rows[n]["CreateEmpId"].ToString());
                    }
                    model.CreateEmp = dt.Rows[n]["CreateEmp"].ToString();
                    if (dt.Rows[n]["BelongCityId"].ToString() != "")
                    {
                        model.BelongCityId = new Guid(dt.Rows[n]["BelongCityId"].ToString());
                    }
                    model.BelongCityName = dt.Rows[n]["BelongCityName"].ToString();
                    if (dt.Rows[n]["BelongCompanyId"].ToString() != "")
                    {
                        model.BelongCompanyId = new Guid(dt.Rows[n]["BelongCompanyId"].ToString());
                    }
                    model.BelongCompany = dt.Rows[n]["BelongCompany"].ToString();
                    if (dt.Rows[n]["BelongDepartId"].ToString() != "")
                    {
                        model.BelongDepartId = new Guid(dt.Rows[n]["BelongDepartId"].ToString());
                    }
                    model.BelongDepart = dt.Rows[n]["BelongDepart"].ToString();
                    if (dt.Rows[n]["BelongEmpId"].ToString() != "")
                    {
                        model.BelongEmpId = new Guid(dt.Rows[n]["BelongEmpId"].ToString());
                    }
                    model.BelongEmp = dt.Rows[n]["BelongEmp"].ToString();
                    if (dt.Rows[n]["DeliverTime"].ToString() != "")
                    {
                        model.DeliverTime = DateTime.Parse(dt.Rows[n]["DeliverTime"].ToString());
                    }
                    if (dt.Rows[n]["LastEmployeeId"].ToString() != "")
                    {
                        model.LastEmployeeId = new Guid(dt.Rows[n]["LastEmployeeId"].ToString());
                    }
                    model.LastEmployee = dt.Rows[n]["LastEmployee"].ToString();
                    if (dt.Rows[n]["LastEmployeeGetTime"].ToString() != "")
                    {
                        model.LastEmployeeGetTime = DateTime.Parse(dt.Rows[n]["LastEmployeeGetTime"].ToString());
                    }
                    if (dt.Rows[n]["BusinessType"].ToString() != "")
                    {
                        model.BusinessType = int.Parse(dt.Rows[n]["BusinessType"].ToString());
                    }
                    if (dt.Rows[n]["IntentionType"].ToString() != "")
                    {
                        model.IntentionType = int.Parse(dt.Rows[n]["IntentionType"].ToString());
                    }
                    if (dt.Rows[n]["UpdateEmpId"].ToString() != "")
                    {
                        model.UpdateEmpId = new Guid(dt.Rows[n]["UpdateEmpId"].ToString());
                    }
                    model.UpdateEmp = dt.Rows[n]["UpdateEmp"].ToString();
                    if (dt.Rows[n]["UpdateTime"].ToString() != "")
                    {
                        model.UpdateTime = DateTime.Parse(dt.Rows[n]["UpdateTime"].ToString());
                    }
                    if (dt.Rows[n]["Status"].ToString() != "")
                    {
                        model.Status = int.Parse(dt.Rows[n]["Status"].ToString());
                    }
                    model.StatusDescription = dt.Rows[n]["StatusDescription"].ToString();
                    if (dt.Rows[n]["HouseId"].ToString() != "")
                    {
                        model.HouseId = new Guid(dt.Rows[n]["HouseId"].ToString());
                    }
                    model.HouseCode = dt.Rows[n]["HouseCode"].ToString();
                    model.HouseAddress = dt.Rows[n]["HouseAddress"].ToString();
                    model.Region = dt.Rows[n]["Region"].ToString();
                    if (dt.Rows[n]["TotalPrice"].ToString() != "")
                    {
                        model.TotalPrice = decimal.Parse(dt.Rows[n]["TotalPrice"].ToString());
                    }
                    model.CustomerName_Sale = dt.Rows[n]["CustomerName_Sale"].ToString();
                    model.CustomerName_Buy = dt.Rows[n]["CustomerName_Buy"].ToString();
                    if (dt.Rows[n]["FirstMoney"].ToString() != "")
                    {
                        model.FirstMoney = decimal.Parse(dt.Rows[n]["FirstMoney"].ToString());
                    }
                    if (dt.Rows[n]["TotalMoney"].ToString() != "")
                    {
                        model.TotalMoney = decimal.Parse(dt.Rows[n]["TotalMoney"].ToString());
                    }
                    if (dt.Rows[n]["GetedMoney"].ToString() != "")
                    {
                        model.GetedMoney = decimal.Parse(dt.Rows[n]["GetedMoney"].ToString());
                    }
                    if (dt.Rows[n]["DeliveredMoney"].ToString() != "")
                    {
                        model.DeliveredMoney = decimal.Parse(dt.Rows[n]["DeliveredMoney"].ToString());
                    }
                    if (dt.Rows[n]["LastContractDate"].ToString() != "")
                    {
                        model.LastContractDate = DateTime.Parse(dt.Rows[n]["LastContractDate"].ToString());
                    }
                    if (dt.Rows[n]["LastDeliverMoneyDate"].ToString() != "")
                    {
                        model.LastDeliverMoneyDate = DateTime.Parse(dt.Rows[n]["LastDeliverMoneyDate"].ToString());
                    }
                    if (dt.Rows[n]["DeliverTo"].ToString() != "")
                    {
                        model.DeliverTo = int.Parse(dt.Rows[n]["DeliverTo"].ToString());
                    }
                    model.LostItems = dt.Rows[n]["LostItems"].ToString();
                    if (dt.Rows[n]["GetAuthorizeDate"].ToString() != "")
                    {
                        model.GetAuthorizeDate = DateTime.Parse(dt.Rows[n]["GetAuthorizeDate"].ToString());
                    }
                    if (dt.Rows[n]["ChangeTime"].ToString() != "")
                    {
                        model.ChangeTime = DateTime.Parse(dt.Rows[n]["ChangeTime"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        //public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        //{
        //return Chenxin.Lib.Business.DAL.t_Intention_BaseInfo.GetList(PageSize,PageIndex,strWhere);
        //}

        #endregion  成员方法
    }
}

